import { Inject, Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response } from 'express';
import { AppService } from './app.service';
import { PersonService } from './person/person.service';

@Injectable()
export class LogMiddleware implements NestMiddleware {
  @Inject(AppService)
  private readonly appService: AppService;

  @Inject(PersonService)
  private readonly personService: PersonService;
  use(req: Request, res: Response, next: () => void) {
    // if (req.method === 'OPTIONS') {
    //   return next();
    // }
    console.log('appService中间件', this.appService.getHello());
    console.log('personService中间件', this.personService.findAll());
    console.log('before222', req.url);
    next();
    console.log('after222');
  }
}
